/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package services;

import javax.persistence.EntityManager;
import services.interfaces.ICommentService;
import javax.persistence.PersistenceContext;
import javax.validation.ConstraintDeclarationException;
import javax.validation.ConstraintViolationException;
import java.util.List;
import models.Comments;
import models.Products;
import models.Questions;
    
/**
 *
 * @author milokokok
 */
public class CommentServiceImpl extends GenericServiceImpl<Comments> implements ICommentService {

    
    @PersistenceContext(unitName="ors-ejbPU2")
    private EntityManager em;
    
    public CommentServiceImpl() {
        super(Comments.class);
    }

    
    @Override
    public List<Comments> getProductsComments(Products product) {
        return (List<Comments>)em.createNamedQuery("Comments.getProductsComments").setParameter("product", product.getId()).getResultList() ;
    }

    @Override
    public List<Comments> getQuestionsComments(Questions question) {
        return (List<Comments>)em.createQuery("Comments.getQuestionsComments").setParameter("id_question", question.getId()).getResultList();
    }


    

    @Override
    protected EntityManager getEntityManager() {
       return  em;
    }

    @Override
    public int count() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void addQuestionAnswer(Questions question, Comments comments) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void delUserComments(Comments comments) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    
	
}